<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__static/lib/layui-v2.5.5/css/layui.css" media="all">
	<link rel="stylesheet" href="__static/css/public.css" media="all">
	<style>
		.layui-form-pane .layui-form-label {
			width: 90px;
		}
		/* .layui-table-cell {
		    height: auto ;
		    white-space: normal;
		} */
	</style>
</head>
<body>
<div class="layuimini-container">
	<div class="layuimini-main">

		<fieldset class="table-search-fieldset layuimini-container">
			<legend>搜索信息</legend>
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item" style="margin-bottom: 5px;">
					<div class="layui-inline">
						<label class="layui-form-label">客户姓名</label>
						<div class="layui-input-inline">
							<input type="text" id="name" autocomplete="off" class="layui-input" placeholder="请输入客户姓名">
						</div>
					</div>
					<div class="layui-inline">
						<button type="button" class="layui-btn layui-btn-primary ss"><i class="layui-icon"></i> 搜 索</button>
					</div>
				</div>
			</form>
		</fieldset>
		<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
		<script type="text/html" id="toolbarDemo">
			<div class="layui-btn-container">
				<button class="layui-btn layui-btn-success layui-btn-sm data-add-btn" lay-event="recharge"> 客户打款 </button>
			</div>
		</script>
		<script type="text/html" id="currentTableBar"> 
			{{d.status<1?'<a class="layui-btn layui-btn-success layui-btn-xs layui-btn-warm" lay-event="edit">修改</a>':''}}
			{{d.status<1?'<a class="layui-btn layui-btn-xs  layui-btn-danger data-count-delete" lay-event="del">删除</a>':''}}
			
		</script>
		<script type="text/html" id="cz_list">
			<span onmouseover=get_msg(this) data-msg="{{d.reject}}" style="color: red;font-weight: bold;{{d.status == -1?'':'display:none;'}}">驳回</span>
			<span  style="color: #03A9F4;font-weight: bold;{{d.status == 0?'':'display:none;'}}">审核中</span>
			<span  style="color: #4CAF50;font-weight: bold;{{d.status == 1?'':'display:none;'}}">打款成功</span>
		</script>
	</div>
</div>
<script src="__static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="__static/js/man.js" charset="utf-8"></script>
<script>
function get_msg(obj){
	var str = $(obj).attr('data-msg');
	layer.tips(str,$(obj));
}
//修改
function get_save(id){
	layer.open({
        type: 2,
        title:'修改客户打款信息',
        area: ['60%', '70%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('save_recharge')}?id="+id 
    });
    //layer.full(index);
}
//客户充值
function add_recharge(){
	layer.open({
        type: 2,
        title:'客户打款',
        area: ['60%', '80%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('add_recharge')}"
    });
    //layer.full(index);
}
	var form, layer,table,$;
	layui.use([ 'form', 'table', 'layedit', 'laydate', 'element' ], function() {
		form = layui.form, layer = layui.layer,table = layui.table,$ = layui.jquery;
		pageLoading();
		table.render({
			elem: '#currentTableId',
			height: 'full-150',
			id:'testReload',
			url: '{:url("recharge")}?t=json',
			method : 'post',
			toolbar: '#toolbarDemo',
			loading:false,
			cols: [[
				{ field: 'code', title: '充值编号' },
				{ field: 'name', title: '客户名称' },
				{ field: 'amount', title: '打款金额' },
				{ field: 'screenshot_url', title: '打款凭证',templet: function(d){
			          return d.screenshot_url?'<img  src="'+d.screenshot_url+'">':''
			    }},
			    { field: 'status', title: '状态' ,templet:'#cz_list'},
			    
			    { field: 'username', title: '媒介' },
			    { field: 'create_time', title: '添加时间'},
				{ field: 'note', title: '备注'},
				{ title: '操作',fixed: 'right', toolbar: '#currentTableBar', align: "center" }
			]],
			limit: 30,
			page: true,
			skin: 'line',
			even: true,
			done: function () {
                // 添加分页加载动画的函数    
                $('.layui-laypage > a').each(function(){
                    $(this).attr('onclick',"pageLoading(this)");
                })
                layer.close(loadingIndex);
            }
		});
		// 监听搜索操作
		$('.ss').click(function(){
			pageLoading();
			var name = $("#name").val();
			table.reload('testReload', {
				  url: '{:url("recharge")}?t=json',
				  where:{name:name}
				});
		});
		/**
		 * toolbar监听事件
		 */
		table.on('toolbar(currentTableFilter)', function (obj) {
			switch (obj.event) {
				case 'recharge':
					//客户充值
					add_recharge();
				break;
				
			}
			
		});
		//监听操作栏
		table.on('tool(currentTableFilter)', function (obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'edit':
					get_save(data.id);
				break;
				case 'del':
					get_del(data.id,obj);
				break;
			}
			
		});
		
		//删除
		function get_del(id,obj){
			layer.confirm('您确认要删除此打款吗？', function(index){
				layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
			  	$.post("{:url('cu_dk_del')}?t=json",{id:id},function(data){
				  	layer.closeAll();
					if (data['code'] == 1) {  
						obj.del();
						layer.msg(data['msg'], { icon : 6 });
					} else {
						layer.msg(data['msg'], { icon : 5 });
					}
			  	})
			});
		}
		//监听行单击事件
		table.on('row(currentTableFilter)', function(obj){
			  layer.photos({
				  photos: obj.tr
				  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
				});
			});

	});
	//重载数据表
	function get_s(msg){
		table.reload('testReload', {
			  url: '{:url("recharge")}?t=json',
			});
		layer.msg(msg, {icon: 6});
	}
</script>

</body>
</html>